; MUI v3.8 iGame dependencies
; ---------------------------
;
; Date: 2021-12-06
; Author: Henrik Noerfjand Stengaard
;
; User package for HstWB Installer to automate installation of iGame dependencies
; MUI TextEditor MCC and guigfx and render libraries.


; paths
set muidir "`execute INSTALLDIR:S/CombinePath "$INSTALLDIR" "System/MUI"`"
set libsdir "`execute INSTALLDIR:S/CombinePath "$INSTALLDIR" "Libs"`"

; Set mui dir to "MUI:", if  device exist
Assign >NIL: EXISTS MUI:
IF $RC EQ 0 VAL
  set muidir "MUI:"
ELSE
  ; skip to end, if default mui directory doesn't exist 
  IF NOT EXISTS "$muidir/mui"
    echo "*e[1mError: Unable to install MUI iGame dependencies,*NMUI: device not found or*NMUI not installed in '$muidir'.*NMUI iGame dependencies can't be installed without this!*e[0m"
    ask "Press ENTER to continue"
    SKIP end
  ENDIF
ENDIF

; set mui libs directory
set muilibsdir "`execute INSTALLDIR:S/CombinePath "$muidir" "Libs/mui"`"

; create mui libs directory, if it doesn't exist
IF NOT EXISTS "$muilibsdir"
  MakePath >NIL: "$muilibsdir"
ENDIF


; write install status
Echo "MUI TextEditor MCC..."

; extract texteditor to temp systemdir
lha -m1 -q x "USERPACKAGEDIR:MCC_TextEditor_68k.lha" "SYSTEMDIR:Temp/_TextEditor/"

; install texteditor files
Copy >NIL: "SYSTEMDIR:Temp/_TextEditor/TextEditor.#?" "$muilibsdir" CLONE ALL

; delete mui from temp systemdir
Delete >NIL: "SYSTEMDIR:Temp/_TextEditor" ALL


; write install status
Echo "MUI Guigfx MCC..."

; extract guigfx to temp systemdir
lha -m1 -q x "USERPACKAGEDIR:MCC_Guigfx.lha" "SYSTEMDIR:Temp/_guigfx/"

; install guigfx files
Copy >NIL: "SYSTEMDIR:Temp/_guigfx/MCC_Guigfx/Libs/MUI/Guigfx.#?" "$muilibsdir" CLONE ALL

; delete guigfx from temp systemdir
Delete >NIL: "SYSTEMDIR:Temp/_guigfx" ALL


; write install status
Echo "Guigfx and render libraries..."

; extract guigfx and render libraries to libs
lha -m1 -q x "USERPACKAGEDIR:guigfx_render_nofpu.lha" "$libsdir/"


; end
; ---
LAB end
